
const request = require('../../../utils/request')
const { computed } = require('../../../utils/computed')

Component({

    behaviors: [],

    properties: {
        roomTable: Array
    },
    data: {
        navIndex: 0,
        roomTitle: ['房间','大厅'],
        swiperHeight: 0,
        imgUrl: request.imgUrl,
        indicatorDots: true,
        autoplay: true,
        circular: false,
        interval: 4000,
        duration: 500,
        room:{},    //房间详情数据
        seeDetail: false    //详情是否可看
    }, // 私有数据，可用于模版渲染

    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached: function () { },
    moved: function () { },
    detached: function () { },
    ready() {
        var that = this 
        computed(this,{
            roomTables: function(){
                let a = [],b=[];
                let arr = [];
                that.data.roomTable.forEach(res => {
                    // let arr = [].concat(res.thumb.split[';'])
                    // res.thumb = arr;
                    // console.log(res.thumb.split[';'])
                    if(res.type == 1){
                        a.push(res);
                    }else{
                        b.push(res)
                    }
                });
                arr.push(a);
                arr.push(b);
                console.log(arr)
                return arr
            }
        })

        //如果用swiper就用下面代码
        // setTimeout(function(){
        //     var query = wx.createSelectorQuery().in(that)
        //     query.selectAll('.room-con').boundingClientRect(function(res){
        //         var height = 0;
        //         for(let i=0; i<res.length-1; i++){
        //             if(res[i].height<res[i+1].height){
        //                 res[i].height = res[i+1].height;
        //             }
        //             height = res[i].height
        //         }
        //         console.log(height)
        //         that.setData({
        //             swiperHeight: height
        //         })
        //     }).exec()
        // },1000)
        
        
    },

    methods: {
        itemLoad(e) {
            console.log(e)
        },
        handleClick(e) {
            this.setData({
                navIndex: e.target.dataset.index
            })
        },
        handleChange(e) {
            this.setData({
                navIndex: e.detail.current
            })
        },
        seeRoom(e) {
            console.log(e)
            let room = e.currentTarget.dataset.room;
            this.setData({
                room: room,
                seeDetail: true
            })
        },
        hiddenDetail() {
            this.setData({
                seeDetail: false
            })
        }
    }

})